home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / c / amiexpress / source / utils / bull / bull.c next >
Encoding:
C/C++ Source or Header  |  1992-12-26  |  2.6 KB  |  121 lines

  1. #include <exec/types.h>
  2. #include <exec/exec.h>
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include "work:romconf/doorheader.h"
  6. #define gu getuserstring
  7. #define pm prompt
  8. #define hk hotkey
  9. #define sm sendmessage
  10. char cmd[200];
  11. void showbull(char *str);
  12. void end();
  13. main(int argc, char *argv[])
  14. {
  15.   FILE *fi;
  16.   char respond[10];
  17.   char filename[200];
  18.   char nodelocal[200];
  19.   char conflocal[200];
  20.   char bbsloc[50];
  21.   int Bconf=0,Bnode=0;
  22.   int node;
  23.   Register(argv[1][0]-'0');
  24.   node = argv[1][0]-'0';
  25.   gu(cmd,BB_CONFLOCAL);
  26.   gu(bbsloc,BB_LOCAL);
  27.  
  28.   sprintf(filename,"%sNode%d/Bulletins/",bbsloc,node);
  29.   strcpy(nodelocal,filename);
  30.  
  31.   sprintf(filename,"%sBulletins/",cmd);
  32.   strcpy(conflocal,filename);
  33.  
  34.   strcpy(filename,nodelocal);
  35.   strcat(filename,"bullhelp.txt");
  36.   fi=fopen(filename,"r");
  37.   if(fi!=NULL) { fclose(fi); Bnode=1; }
  38.  
  39.   strcpy(filename,conflocal);
  40.   strcat(filename,"bullhelp.txt");
  41.   fi=fopen(filename,"r");
  42.   if(fi!=NULL) {  Bconf=1; fclose(fi); }
  43.   sm("",1);
  44.   while(1)
  45.   {
  46.     if(Bnode==1 && Bconf==1)
  47.     {
  48.       sm("Please enter bulletin type N)ode or C)onference or {return=exit}>:",0);
  49.       hk("",cmd);
  50.       if(cmd[0]<' ') { sm("",1);sm("",1);ShutDown(); end(); }
  51.       if(cmd[0]=='N' || cmd[0]=='n')
  52.       {
  53.          sm("Node.",1);
  54.          showbull(nodelocal);
  55.       }
  56.       if(cmd[0]=='C' || cmd[0]=='c')
  57.       {
  58.          sm("conference.",1);
  59.          showbull(conflocal);
  60.       }
  61.     }
  62.     if(Bnode==0 && Bconf==1)
  63.     {
  64.       showbull(conflocal);
  65.     }
  66.     if(Bnode==1 && Bconf==0)
  67.     {
  68.       showbull(nodelocal);
  69.     }
  70.     if(Bnode==0 && Bconf==0)
  71.     {
  72.       sm("Sorry, we have no bulletins",1);
  73.       sm("",1);
  74.       ShutDown(); end();
  75.     }
  76.    }
  77. }
  78.  
  79. void showbull(char *str)
  80. {
  81.   char string[200];
  82.   char cmd[200];
  83.   FILE *fi;
  84.   int num;
  85.   strcpy(string,str);
  86.   strcat(string,"BullHelp");
  87.   showgfile(string);
  88.   
  89.   while(1)
  90.   {
  91.     sm("",1);
  92.     sm("Type '?' {RETURN} to view menu",1);
  93.     pm("Enter bulletin number you wish to view or {RETURN to exit} >:",cmd,5);
  94.     num=atoi(cmd);
  95.     if(cmd[0]=='?')
  96.     {
  97.       strcpy(string,str);strcat(string,"BullHelp");
  98.       showgfile(string);
  99.       continue;
  100.     }
  101.     sm("",1);
  102.     if(num==0){ sm("",1); ShutDown(); end(); }
  103.     sprintf(string,"%sBull%d.txt",str,num);
  104.     fi=fopen(string,"r");
  105.     if(fi==NULL)
  106.     {
  107.       sm("",1);
  108.       sm("Sorry, can't locate that Bulletin",1);
  109.       continue;
  110.     }
  111.     fclose(fi);
  112.     sprintf(string,"%sBull%d",str,num);
  113.     showgfile(string);
  114.   }
  115.   
  116. }
  117.   
  118. void end()
  119. {
  120.   exit(0);
  121. }